package com.hu.boot.controller;

import com.hu.boot.exception.UserNameNotFoundException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ExceptionController {

    @GetMapping("/exception/{username}")
    public ResponseEntity<String> exception(@PathVariable("username") String username) {
        if ("admin".equals(username)) {
            throw new UserNameNotFoundException("自定义异常");
        }
        throw new RuntimeException("普通异常");
//        return new ResponseEntity<>("ok", HttpStatus.OK);
    }

}
